/*
 * @Author: wuzhiquan
 * @Date: 2020-11-25
 */
const path = require('path');
function resolve(dir) {
  return path.join(__dirname, dir);
}
const port = 8979;
const { name } = require('./package.json');
const AutoImport = require('unplugin-auto-import/webpack');

module.exports = {
  publicPath: './',
  transpileDependencies: ['global-state'],

  // filenameHashing: false, // 去除Vue打包后.css和.js文件名称中8位hash值，跟缓存有关；一般为true就行。
  productionSourceMap: false,
  devServer: {
    // proxy: {
    //     // detail: https://cli.vuejs.org/config/#devserver-proxy
    //     [process.env.VUE_APP_BASE_API]: {
    //         target: `http://192.168.10.24:18000`,
    //         // target: `http://192.168.10.226:28080`,
    //         changeOrigin: true,
    //         pathRewrite: {
    //             ['^' + process.env.VUE_APP_BASE_API]: ''
    //         }
    //     }
    // },
    port,
    headers: {
      'Access-Control-Allow-Origin': '*',
    },
  },
  configureWebpack: {
    name: name,
    resolve: {
      alias: {
        '@': resolve('./src'),
      },
    },
    plugins: [
      AutoImport({
        imports: ['vue', 'vue-router', 'pinia'],
        dts: false, // 支持TS类型提示
        eslintrc: {
          enabled: false, // Default `false`
          filepath: './.eslintrc-auto-import.json', // Default `./.eslintrc-auto-import.json`
          globalsPropValue: true, // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
        },
      }),
    ],
    output: {
      // 把子应用打包成 umd 库格式
      library: `${name}-[name]`,
      libraryTarget: 'umd',
      jsonpFunction: `webpackJsonp_${name}`,
    },
  },
};
